home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Commodities / Watcher / Sources / Sources.lha / WatcherPrefs / WatcherPrefs_t.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-06  |  31.6 KB  |  1,152 lines

  1. /*««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*/
  2. /*                            I N C L U D E S                                    */
  3. /*««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*/
  4. #include <exec/types.h>                                // For UBYTE etc.
  5. #include <clib/exec_protos.h>                        // Protos for CopyMem() etc.
  6. #include <clib/gadtools_protos.h>                // Protos for GT_SetGadgetAttrs() etc.
  7. #include <dos/notify.h>                                // For notification structs etc.
  8. #include <intuition/gadgetclass.h>                // Misc defines etc.
  9. #include <libraries/gadtools.h>                    // For gadtools structures etc.
  10. #include <pragmas/exec_pragmas.h>                // Pragmas for exec.library.
  11. #include <pragmas/gadtools_pragmas.h>            // Pragmas for gadtools.library.
  12. #include <stdlib.h>                                    // Protos for atoi() etc.
  13. #include <string.h>                                    // Protos for strcpy() etc.
  14.  
  15. #include "WatcherPrefs.h"                            // GadTools generated.
  16. #include "/Include/Defines.h"                        // Gadget defines etc.
  17. #include "/Include/Prefs.h"                        // For WPrefs structure.
  18.  
  19. /*««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*/
  20. /*                             I M P O R T S                                        */
  21. /*««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*/
  22. /*------------*/
  23. /* Variables: */
  24. /*------------*/
  25. extern ULONG                What;                        // Determines wheter a checkmark is active.
  26. extern struct WPrefs        *WPrefs;                    // Main preference settings.
  27. extern struct WPrefs        *WPrefsBack;            // Backup for restore purposes.
  28. extern struct Requester    SleepReq;                // For SleepWindow() etc.
  29. /*------------*/
  30. /* Functions: */
  31. /*------------*/
  32. extern BOOL    ReadPrefs            (UBYTE *fname);
  33. extern BOOL WritePrefs            (UBYTE *fname);
  34. extern void CorrectGadgets        (struct WPrefs *wprefs);
  35. extern void UsePrefsDefaults    (void);
  36. extern BOOL    Inform                (struct Window *w, STRPTR Title, STRPTR Text, APTR args);
  37. extern BOOL RequestPrefFile    (UBYTE *startdir, UBYTE *startfile, UBYTE *resultpath, UBYTE *title);
  38. extern void    SplitPath            (STRPTR FullPath, STRPTR PathPart, STRPTR NamePart);
  39. extern BOOL    SleepWindow            (struct Window *w, struct Requester *r);
  40. extern void    WakeUpWindow        (struct Window *w, struct Requester *r);
  41.  
  42. /*««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*/
  43. /*                           F U N C T I O N S                                    */
  44. /*««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*/
  45. // This file contains empty template routines that the IDCMP handler
  46. // will call uppon. Fill out these routines with your code or use them
  47. // as a reference to create your program.
  48.  
  49. int VOLUMESClicked( void )
  50. {
  51.     /* routine when gadget "Volumes:" is clicked. */
  52.  
  53.     /*-------------*/
  54.     /* L O C A L S */
  55.     /*-------------*/
  56.     UBYTE *s, scopy [256];
  57.     ULONG SCount = 0;
  58.  
  59.     /*---------*/
  60.     /* C O D E */
  61.     /*---------*/
  62.     strcpy (WPrefs->wp_VolNameStrGad,
  63.               ((struct StringInfo *) WatcherPrefsGadgets [GD_VOLUMES]->SpecialInfo)->Buffer);
  64.     s = WPrefs->wp_VolNameStrGad;
  65.  
  66.     while (*s)
  67.     {
  68.         switch (*s)
  69.         {
  70.             case ':' :
  71.             {
  72.                 scopy [SCount++] = ':';                // Copy also ':' into scopy.
  73.                 scopy [SCount] = '\0';                // NULL terminate scopy.
  74.                 strcpy (WPrefs->wp_VolName [WPrefs->wp_VolCount], scopy);
  75.                 scopy [SCount = 0] = '\0';            // NULL scopy.
  76.                 *s++;                                        // Advance one character.
  77.                 if (*s == '-')                            // Check for indicator.
  78.                 {
  79.                     *s++;
  80.                     if ((*s == 'b') || (*s == 'B'))
  81.                     {
  82.                         WPrefs->wp_VolNameType [WPrefs->wp_VolCount] = VBYTE;
  83.                     }
  84.                     if ((*s == 'k') || (*s == 'K'))
  85.                     {
  86.                         WPrefs->wp_VolNameType [WPrefs->wp_VolCount] = VKILOBYTE;
  87.                     }
  88.                     if ((*s == 'm') || (*s == 'M'))
  89.                     {
  90.                         WPrefs->wp_VolNameType [WPrefs->wp_VolCount] = VMEGABYTE;
  91.                     }
  92.                     if ((*s == 'a') || (*s == 'A'))
  93.                     {
  94.                         WPrefs->wp_VolNameType [WPrefs->wp_VolCount] = VAUTO;
  95.                     }
  96.                 }
  97.                 WPrefs->wp_VolCount++;
  98.                 *s++;
  99.                 break;
  100.             }
  101.             case ',' :
  102.             {
  103.                 *s++;
  104.                 scopy [SCount = 0] = '\0';
  105.                 break;
  106.             }
  107.             case '-' :
  108.             {
  109.                 break;
  110.             }
  111.             default :
  112.             {
  113.                 scopy [SCount++] = *s++;
  114.                 break;
  115.             }
  116.         }
  117.     }
  118.     return (1);
  119. }
  120.  
  121. int TOTALClicked( void )
  122. {
  123.     /* routine when gadget "Total Memory:" is clicked. */
  124.     if (WatcherPrefsGadgets [GD_TOTAL]->Flags & SELECTED)
  125.     {
  126.         WPrefs->wp_Total = TRUE;
  127.     }
  128.     else
  129.     {
  130.         WPrefs->wp_Total = FALSE;
  131.     }
  132.     return (1);
  133. }
  134.  
  135. int FASTClicked( void )
  136. {
  137.     /* routine when gadget "Fast Memory:" is clicked. */
  138.     if (WatcherPrefsGadgets [GD_FAST]->Flags & SELECTED)
  139.     {
  140.         WPrefs->wp_Fast = TRUE;
  141.     }
  142.     else
  143.     {
  144.         WPrefs->wp_Fast = FALSE;
  145.     }
  146.     return (1);
  147. }
  148.  
  149. int CHIPClicked( void )
  150. {
  151.     /* routine when gadget "Chip Memory:" is clicked. */
  152.     if (WatcherPrefsGadgets [GD_CHIP]->Flags & SELECTED)
  153.     {
  154.         WPrefs->wp_Chip = TRUE;
  155.     }
  156.     else
  157.     {
  158.         WPrefs->wp_Chip = FALSE;
  159.     }
  160.     return (1);
  161. }
  162.  
  163. int LARGESTClicked( void )
  164. {
  165.     /* routine when gadget "Largest Mem. Block:" is clicked. */
  166.     if (WatcherPrefsGadgets [GD_LARGEST]->Flags & SELECTED)
  167.     {
  168.         WPrefs->wp_Largest = TRUE;
  169.     }
  170.     else
  171.     {
  172.         WPrefs->wp_Largest = FALSE;
  173.     }
  174.     return (1);
  175. }
  176.  
  177. int LARGESTFASTClicked( void )
  178. {
  179.     /* routine when gadget "Largest Fast Block:" is clicked. */
  180.     if (WatcherPrefsGadgets [GD_LARGESTFAST]->Flags & SELECTED)
  181.     {
  182.         WPrefs->wp_LargestFast = TRUE;
  183.     }
  184.     else
  185.     {
  186.         WPrefs->wp_LargestFast = FALSE;
  187.     }
  188.     return (1);
  189. }
  190.  
  191. int LARGESTCHIPClicked( void )
  192. {
  193.     /* routine when gadget "Largest Chip Block:" is clicked. */
  194.     if (WatcherPrefsGadgets [GD_LARGESTCHIP]->Flags & SELECTED)
  195.     {
  196.         WPrefs->wp_LargestChip = TRUE;
  197.     }
  198.     else
  199.     {
  200.         WPrefs->wp_LargestChip = FALSE;
  201.     }
  202.     return (1);
  203. }
  204.  
  205. int DAYOFWEEKClicked( void )
  206. {
  207.     /* routine when gadget ":Day of week" is clicked. */
  208.     if (WatcherPrefsGadgets [GD_DAYOFWEEK]->Flags & SELECTED)
  209.     {
  210.         WPrefs->wp_DayOfWeek = TRUE;
  211.     }
  212.     else
  213.     {
  214.         WPrefs->wp_DayOfWeek = FALSE;
  215.     }
  216.     return (1);
  217. }
  218.  
  219. int DATEClicked( void )
  220. {
  221.     /* routine when gadget ":Date" is clicked. */
  222.     if (WatcherPrefsGadgets [GD_DATE]->Flags & SELECTED)
  223.     {
  224.         WPrefs->wp_Date = TRUE;
  225.     }
  226.     else
  227.     {
  228.         WPrefs->wp_Date = FALSE;
  229.     }
  230.     return (1);
  231. }
  232.  
  233. int TIMEClicked( void )
  234. {
  235.     /* routine when gadget ":Time" is clicked. */
  236.     if (WatcherPrefsGadgets [GD_TIME]->Flags & SELECTED)
  237.     {
  238.         WPrefs->wp_Time = TRUE;
  239.     }
  240.     else
  241.     {
  242.         WPrefs->wp_Time = FALSE;
  243.     }
  244.     return (1);
  245. }
  246.  
  247. int WINLEFTEDGEClicked( void )
  248. {
  249.     /* routine when gadget "Window LeftEdge:" is clicked. */
  250.     WPrefs->wp_WinLeftEdge = atoi (((struct StringInfo *)
  251.                                             WatcherPrefsGadgets [GD_WINLEFTEDGE]->SpecialInfo)->Buffer);
  252.     return (1);
  253. }
  254.  
  255. int WINTOPEDGEClicked( void )
  256. {
  257.     /* routine when gadget "Window TopEdge:" is clicked. */
  258.     WPrefs->wp_WinTopEdge = atoi (((struct StringInfo *)
  259.                                             WatcherPrefsGadgets [GD_WINTOPEDGE]->SpecialInfo)->Buffer);
  260.     return (1);
  261. }
  262.  
  263. int WINWIDTHClicked( void )
  264. {
  265.     /* routine when gadget "Window Width:" is clicked. */
  266.     WPrefs->wp_WinWidth = atoi (((struct StringInfo *)
  267.                                         WatcherPrefsGadgets [GD_WINWIDTH]->SpecialInfo)->Buffer);
  268.     return (1);
  269. }
  270.  
  271. int UPDATESECClicked( void )
  272. {
  273.     /* routine when gadget "Update rate sec.:" is clicked. */
  274.     WPrefs->wp_UpdateSec = atoi (((struct StringInfo *)
  275.                                          WatcherPrefsGadgets [GD_UPDATESEC]->SpecialInfo)->Buffer);
  276.  
  277.     if ((WPrefs->wp_UpdateSec < 1) && (WPrefs->wp_UpdateMic == 0))
  278.     {
  279.         Inform (WatcherPrefsWnd, "Error", "Your can't have zeroes in both seconds and\n"
  280.                                                      "microseconds. Specify at least one of the\n"
  281.                                                      "two.", NULL);
  282.     }
  283.     return (1);
  284. }
  285.  
  286. int UPDATEMICClicked( void )
  287. {
  288.     /* routine when gadget "Update rate mic.:" is clicked. */
  289.     WPrefs->wp_UpdateMic = atoi (((struct StringInfo *)
  290.                                          WatcherPrefsGadgets [GD_UPDATEMIC]->SpecialInfo)->Buffer);
  291.  
  292.     if ((WPrefs->wp_UpdateMic < 1) && (WPrefs->wp_UpdateSec == 0))
  293.     {
  294.         Inform (WatcherPrefsWnd, "Error", "Your can't have zeroes in both seconds and\n"
  295.                                                      "microseconds. Specify at least one of the\n"
  296.                                                      "two.", NULL);
  297.     }
  298.     return (1);
  299. }
  300.  
  301. int NOJUMPGADGETClicked( void )
  302. {
  303.     /* routine when gadget ":No Jump Gadget" is clicked. */
  304.     if (WatcherPrefsGadgets [GD_NOJUMPGADGET]->Flags & SELECTED)
  305.     {
  306.         WPrefs->wp_NoJumpGadget = TRUE;
  307.     }
  308.     else
  309.     {
  310.         WPrefs->wp_NoJumpGadget = FALSE;
  311.     }
  312.     return (1);
  313. }
  314.  
  315. int CPUClicked( void )
  316. {
  317.     /* routine when gadget ":CPU load" is clicked. */
  318.     if (WatcherPrefsGadgets [GD_CPU]->Flags & SELECTED)
  319.     {
  320.         WPrefs->wp_Cpu = TRUE;
  321.     }
  322.     else
  323.     {
  324.         WPrefs->wp_Cpu = FALSE;
  325.     }
  326.     return (1);
  327. }
  328.  
  329. int PUBLICSCREENClicked( void )
  330. {
  331.     /* routine when gadget "Public Screen:" is clicked. */
  332.     strcpy (WPrefs->wp_PubScreen,
  333.               ((struct StringInfo *) WatcherPrefsGadgets [GD_PUBLICSCREEN]->SpecialInfo)->Buffer);
  334.     return (1);
  335. }
  336.  
  337. int GUIDEFILEClicked( void )
  338. {
  339.     /* routine when gadget "Guide file:" is clicked. */
  340.     strcpy (WPrefs->wp_GuideFile,
  341.               ((struct StringInfo *) WatcherPrefsGadgets [GD_GUIDEFILE]->SpecialInfo)->Buffer);
  342.     return (1);
  343. }
  344.  
  345. int VOLUMEFREEDIRECTIONClicked( void )
  346. {
  347.     /* routine when gadget ":Vol. Free Dir." is clicked. */
  348.     if (WatcherPrefsGadgets [GD_VOLUMEFREEDIRECTION]->Flags & SELECTED)
  349.     {
  350.         WPrefs->wp_VolumeFreeDirection = TRUE;
  351.         GT_SetGadgetAttrs (WatcherPrefsGadgets [GD_VOLUMEFREEDIRECTIONINDICATORS],
  352.                                  WatcherPrefsWnd, NULL,
  353.                                  GA_Disabled, FALSE,
  354.                                  TAG_END);
  355.     }
  356.     else
  357.     {
  358.         WPrefs->wp_VolumeFreeDirection = FALSE;
  359.         GT_SetGadgetAttrs (WatcherPrefsGadgets [GD_VOLUMEFREEDIRECTIONINDICATORS],
  360.                                  WatcherPrefsWnd, NULL,
  361.                                  GA_Disabled, TRUE,
  362.                                  TAG_END);
  363.     }
  364.     return (1);
  365. }
  366.  
  367. int VOLUMEFREEDIRECTIONINDICATORSClicked( void )
  368. {
  369.     /* routine when gadget "Volume Free Indicators" is clicked. */
  370.     strcpy (WPrefs->wp_VolumeFreeDirectionInd,
  371.               ((struct StringInfo *)
  372.               WatcherPrefsGadgets [GD_VOLUMEFREEDIRECTIONINDICATORS]->SpecialInfo)->Buffer);
  373.     return (1);
  374. }
  375.  
  376. int VOLUMALERTClicked( void )
  377. {
  378.     /* routine when gadget "Volume Alert:" is clicked. */
  379.     strcpy ((UBYTE *) WPrefs->wp_VolAlertStrGad,
  380.               ((struct StringInfo *) WatcherPrefsGadgets [GD_VOLUMALERT]->SpecialInfo)->Buffer);
  381.     return (1);
  382. }
  383.  
  384. int SAVEClicked( void )
  385. {
  386.     /* routine when gadget "_Save" is clicked. */
  387.     if (!(WritePrefs ("ENVARC:Watcher.prefs")))
  388.     {
  389.         Inform (WatcherPrefsWnd, "Error:", "Can't write to ENVARC:Watcher.prefs", NULL);
  390.     }
  391.     if (!(WritePrefs ("ENV:Watcher.prefs")))
  392.     {
  393.         Inform (WatcherPrefsWnd, "Error:", "Can't write to ENV:Watcher.prefs", NULL);
  394.     }
  395.     return (0);
  396. }
  397.  
  398. int USEClicked( void )
  399. {
  400.     /* routine when gadget "_Use" is clicked. */
  401.     WritePrefs ("ENV:Watcher.prefs");
  402.     return (0);
  403. }
  404.  
  405. int CANCELClicked( void )
  406. {
  407.     /* routine when gadget "_Cancel" is clicked. */
  408.     return (0);
  409. }
  410.  
  411. int GUIDEFILEGETClicked( void )
  412. {
  413.     /* routine when gadget "" is clicked. */
  414.     /*-------------*/
  415.     /* L O C A L S */
  416.     /*-------------*/
  417.     UBYTE resultpath    [256];
  418.     UBYTE    dir            [256];
  419.     UBYTE file            [256];
  420.  
  421.     /*---------*/
  422.     /* C O D E */
  423.     /*---------*/
  424.     /*----------------------*/
  425.     /* Reset our variables. */
  426.     /*----------------------*/
  427.     dir [0] = '\0';
  428.     file [0] = '\0';
  429.  
  430.     /*-----------------------------------------------------------------------------------*/
  431.     /* Split the path from the string gadget into components suitable for asl requester. */
  432.     /*-----------------------------------------------------------------------------------*/
  433.     SplitPath (((struct StringInfo *) WatcherPrefsGadgets [GD_GUIDEFILE]->SpecialInfo)->Buffer,
  434.                   dir, file);
  435.     
  436.     /*-------------------*/
  437.     /* Put up requester. */
  438.     /*-------------------*/
  439.     SleepWindow (WatcherPrefsWnd, &SleepReq);
  440.     if (RequestPrefFile (dir, file, resultpath, "Choose Watcher guide file."))
  441.     {
  442.         strcpy ((UBYTE *) WPrefs->wp_GuideFile, resultpath);
  443.         CorrectGadgets (WPrefs);
  444.     }
  445.     WakeUpWindow (WatcherPrefsWnd, &SleepReq);
  446.     return (1);
  447. }
  448.  
  449. int APPINFOAUTOSTARTClicked( void )
  450. {
  451.     /* routine when gadget "App Info autostart:" is clicked. */
  452.     if (WatcherPrefsGadgets [GD_APPINFOAUTOSTART]->Flags & SELECTED)
  453.     {
  454.         WPrefs->wp_AppInfoAutoStart = TRUE;
  455.     }
  456.     else
  457.     {
  458.         WPrefs->wp_AppInfoAutoStart = FALSE;
  459.     }
  460.     return (1);
  461. }
  462.  
  463. int APPINFOLEFTEDGEClicked( void )
  464. {
  465.     /* routine when gadget "App Info Left Edge:" is clicked. */
  466.     WPrefs->wp_AppInfoLeftEdge = atoi (((struct StringInfo *)
  467.                                                  WatcherPrefsGadgets [GD_APPINFOLEFTEDGE]->SpecialInfo)->Buffer);
  468.     return (1);
  469. }
  470.  
  471. int APPINFOTOPEDGEClicked( void )
  472. {
  473.     /* routine when gadget "App Info Top Edge:" is clicked. */
  474.     WPrefs->wp_AppInfoTopEdge = atoi (((struct StringInfo *)
  475.                                                 WatcherPrefsGadgets [GD_APPINFOTOPEDGE]->SpecialInfo)->Buffer);
  476.     return (1);
  477. }
  478.  
  479. int LANGUAGEClicked( void )
  480. {
  481.     /* routine when gadget "Language" is clicked. */
  482.     WPrefs->wp_LanguageNum = WatcherPrefsMsg.Code;
  483.     switch (WatcherPrefsMsg.Code)
  484.     {
  485.         case 0 :                                            // dansk
  486.         {
  487.             strcpy (WPrefs->wp_Language, "dansk");
  488.             break;
  489.         }
  490.         case 1 :                                            // english
  491.         case 2 :                                            // internal
  492.         {
  493.             strcpy (WPrefs->wp_Language, "english");
  494.             break;
  495.         }
  496.     }
  497.     return (1);
  498. }
  499.  
  500. int TIME_FORMATClicked( void )
  501. {
  502.     /* routine when gadget ":24 hour clock" is clicked. */
  503.     if (WatcherPrefsGadgets [GD_TIME_FORMAT]->Flags & SELECTED)
  504.     {
  505.         WPrefs->wp_TimeFormat24 = TRUE;
  506.     }
  507.     else
  508.     {
  509.         WPrefs->wp_TimeFormat24 = FALSE;
  510.     }
  511.     return (1);
  512. }
  513.  
  514. int DATE_FORMATClicked( void )
  515. {
  516.     /* routine when gadget "Date F.:" is clicked. */
  517.     WPrefs->wp_DateFormat = WatcherPrefsMsg.Code;
  518.     return (1);
  519. }
  520.  
  521. int WatcherPrefsItem0( void )
  522. {
  523.     /* routine when (sub)item "Open" is selected. */
  524.     /*-------------*/
  525.     /* L O C A L S */
  526.     /*-------------*/
  527.     UBYTE resultpath [256];
  528.  
  529.     /*---------*/
  530.     /* C O D E */
  531.     /*---------*/
  532.     SleepWindow (WatcherPrefsWnd, &SleepReq);
  533.     if (RequestPrefFile ("SYS:Prefs/Presets", "", resultpath, "Open preference"))
  534.     {
  535.         ReadPrefs (resultpath);
  536.         CorrectGadgets (WPrefs);
  537.     }
  538.     WakeUpWindow (WatcherPrefsWnd, &SleepReq);
  539.     return (1);
  540. }
  541.  
  542. int WatcherPrefsItem1( void )
  543. {
  544.     /* routine when (sub)item "Save as..." is selected. */
  545.     /*-------------*/
  546.     /* L O C A L S */
  547.     /*-------------*/
  548.     UBYTE resultpath [256];
  549.  
  550.     /*---------*/
  551.     /* C O D E */
  552.     /*---------*/
  553.     SleepWindow (WatcherPrefsWnd, &SleepReq);
  554.     if (RequestPrefFile ("SYS:Prefs/Presets", "", resultpath, "Save preferences as..."))
  555.     {
  556.         WritePrefs (resultpath);
  557.     }
  558.     WakeUpWindow (WatcherPrefsWnd, &SleepReq);
  559.     return (1);
  560. }
  561.  
  562. int WatcherPrefsItem2( void )
  563. {
  564.     /* routine when (sub)item "Quit" is selected. */
  565.     return (0);
  566. }
  567.  
  568. int WatcherPrefsItem3( void )
  569. {
  570.     /* routine when (sub)item "Reset to defaults" is selected. */
  571.     UsePrefsDefaults ();
  572.     CorrectGadgets (WPrefs);
  573.     return (1);
  574. }
  575.  
  576. int WatcherPrefsItem4( void )
  577. {
  578.     /* routine when (sub)item "Last Saved" is selected. */
  579.     if (!(ReadPrefs ("ENVARC:Watcher.prefs")))
  580.     {
  581.         if (!(ReadPrefs ("ENV:Watcher.prefs")))
  582.         {
  583.             Inform (WatcherPrefsWnd, "Error", "Can't find Watcher.prefs in either ENVARC:,"
  584.                                                          "nor ENV:.", NULL);
  585.             return (1);
  586.         }
  587.     }
  588.     CorrectGadgets (WPrefs);
  589.     return (1);
  590. }
  591.  
  592. int WatcherPrefsItem5( void )
  593. {
  594.     /* routine when (sub)item "Restore" is selected. */
  595.     CopyMem (WPrefsBack, WPrefs, sizeof (struct WPrefs));
  596.     CorrectGadgets (WPrefs);
  597.     return (1);
  598. }
  599.  
  600. int WatcherPrefsItem6( void )
  601. {
  602.     /* routine when (sub)item "Create Icons" is selected. */
  603.     return (1);
  604. }
  605.  
  606. int WatcherPrefsCloseWindow( void )
  607. {
  608.     /* routine for "IDCMP_CLOSEWINDOW". */
  609.     return (0);
  610. }
  611.  
  612. int WatcherPrefsMenuHelp( void )
  613. {
  614.     /* routine for "IDCMP_MENUHELP". */
  615.     /*-------------*/
  616.     /* L O C A L S */
  617.     /*-------------*/
  618.     ULONG menunum, itemnum;
  619.  
  620.     /*---------*/
  621.     /* C O D E */
  622.     /*---------*/
  623.     menunum = MENUNUM (WatcherPrefsMsg.Code);
  624.     itemnum = ITEMNUM (WatcherPrefsMsg.Code);
  625.  
  626.     switch (menunum)
  627.     {
  628.         case 0 :                                            // Project.
  629.         {
  630.             switch (itemnum)
  631.             {
  632.                 case 0 :                                    // Open
  633.                 {
  634.                     Inform (WatcherPrefsWnd, "Help on - Open -",
  635.                               "This lets you open a Watcher preference file. Usually these\n"
  636.                               "reside in the SYS:Prefs/Presets drawer, where you can store\n"
  637.                               "different settings for Watcher.", NULL);
  638.                     break;
  639.                 }
  640.                 case 1 :
  641.                 {
  642.                     Inform (WatcherPrefsWnd, "Help on - Save as... -",
  643.                               "This lets you save the current settings to a file by your\n"
  644.                               "choice. Note that the suggested drawer is SYS:Prefs/Presets,\n"
  645.                               "which is also the drawer used by the Workbench preferences\n"
  646.                               "programs. In this drawer you can save different settings\n"
  647.                               "for different purposes.", NULL);
  648.                     break;
  649.                 }
  650.                 case 3 :
  651.                 {
  652.                     Inform (WatcherPrefsWnd, "Help on - Quit -",
  653.                               "This will quit WatcherPrefs without saving the preferences.", NULL);
  654.                     break;
  655.                 }
  656.             }
  657.             break;
  658.         }
  659.         case 1 :                                            // Edit
  660.         {
  661.             switch (itemnum)
  662.             {
  663.                 case 0 :                                    // Reset to defaults
  664.                 {
  665.                     Inform (WatcherPrefsWnd, "Help on - Reset to defaults -",
  666.                               "This will reset the preference setting to WatcherPrefs'\n"
  667.                               "internal defaults.", NULL);
  668.                     break;
  669.                 }
  670.                 case 1 :                                    // Last saved.
  671.                 {
  672.                     Inform (WatcherPrefsWnd, "Help on - Quit -",
  673.                               "This will load the preference settings from ENVARC:Watcher.prefs.", NULL);
  674.                     break;
  675.                 }
  676.                 case 3 :                                    // Restore.
  677.                 {
  678.                     Inform (WatcherPrefsWnd, "Help on - Quit -",
  679.                               "Restore will set the preference settings as they were when you\n"
  680.                               "started the WatcherPrefs program. This option is useful if you\n"
  681.                               "would like to undo an incorrect save of the preferences.", NULL);
  682.                     break;
  683.                 }
  684.             }
  685.             break;
  686.         }
  687.         case 2 :                                            // Settings
  688.         {
  689.             switch (itemnum)
  690.             {
  691.                 case 0 :                                    // Create Icons?
  692.                 {
  693.                     Inform (WatcherPrefsWnd, "Help on - Quit -",
  694.                               "This will switch between creating icons or not.", NULL);
  695.                     break;
  696.                 }
  697.             }
  698.             break;
  699.         }
  700.     }
  701.     return (1);
  702. }
  703.  
  704. int WatcherPrefsVanillaKey( void )
  705. {
  706.     /* routine for "IDCMP_VANILLAKEY". */
  707.     switch (WatcherPrefsMsg.Code)
  708.     {
  709.         case 's' :
  710.         case 'S' :                                        // Save.
  711.         {
  712.             WritePrefs ("ENVARC:Watcher.prefs");
  713.             WritePrefs ("ENV:Watcher.prefs");
  714.             return (0);
  715.             break;
  716.         }
  717.         case 'u' :
  718.         case 'U' :
  719.         {
  720.             WritePrefs ("ENV:Watcher.prefs");
  721.             return (0);
  722.             break;
  723.         }
  724.         case 'c' :
  725.         case 'C' :                                        // Cancel.
  726.         {
  727.             return (0);
  728.             break;
  729.         }
  730.     }
  731.     return (1);
  732. }
  733.  
  734. int WatcherPrefsRawKey( void )
  735. {
  736.     /* routine for "IDCMP_RAWKEY". */
  737.     /*-------------*/
  738.     /* L O C A L S */
  739.     /*-------------*/
  740.     UWORD x, y;
  741.  
  742.     /*---------*/
  743.     /* C O D E */
  744.     /*---------*/
  745.     x = WatcherPrefsMsg.MouseX;
  746.     y = WatcherPrefsMsg.MouseY;
  747.  
  748.     switch (WatcherPrefsMsg.Code)
  749.     {
  750.         case 95 :
  751.         {
  752.             /*-------------------*/
  753.             /* Check GD_VOLUMES: */
  754.             /*-------------------*/
  755.             if (x >= 86 && x <= 270 && y >= 31 && y <= 44)
  756.             {
  757.                 Inform (WatcherPrefsWnd, "Help on gadget - Volumes -",
  758.                           "Here you enter the names of the volumes you want to watch,\n"
  759.                           "separated with commas.\n\n"
  760.                           "Example: SYS:-a,WORK:-m\n\n"
  761.                           "Will display the free bytes for SYS: in automatic (-a) mode,\n"
  762.                           "which means Watcher is intelligent enough to choose between\n"
  763.                           "MB, KB and bytes depending on the free space. Furthermore,\n"
  764.                           "WORK: will be displayed with free space in megabytes (-m)", NULL);
  765.                 break;
  766.             }
  767.  
  768.             /*-----------------*/
  769.             /* Check GD_TOTAL: */
  770.             /*-----------------*/
  771.             if (x >= 434 && x <= 459 && y >= 84 && y <= 94)
  772.             {
  773.                 Inform (WatcherPrefsWnd, "Help on gadget - Total -",
  774.                           "This gadget toggles between displaying the total amount of\n"
  775.                           "memory available on your system.", NULL);
  776.                 break;
  777.             }
  778.  
  779.             /*----------------*/
  780.             /* Check GD_FAST: */
  781.             /*----------------*/
  782.             if (x >= 434 && x <= 459 && y >= 73 && y <= 83)
  783.             {
  784.                 Inform (WatcherPrefsWnd, "Help on gadget - Fast -",
  785.                           "This gadget toggles between displaying the total amount of\n"
  786.                           "*Fast* memory available on your system.", NULL);
  787.                 break;
  788.             }
  789.  
  790.             /*----------------*/
  791.             /* Check GD_CHIP: */
  792.             /*----------------*/
  793.             if (x >= 434 && x <= 459 && y >= 62 && y <= 72)
  794.             {
  795.                 Inform (WatcherPrefsWnd, "Help on gadget - Chip -",
  796.                           "This gadget toggles between displaying the total amount of\n"
  797.                           "*Chip* memory available on your system.", NULL);
  798.                 break;
  799.             }
  800.  
  801.             /*-------------------*/
  802.             /* Check GD_LARGEST: */
  803.             /*-------------------*/
  804.             if (x >= 434 && x <= 459 && y >= 51 && y <= 61)
  805.             {
  806.                 Inform (WatcherPrefsWnd, "Help on gadget - Largest -",
  807.                           "This gadget toggles between displaying the largest memory\n"
  808.                           "block available on your system.", NULL);
  809.                 break;
  810.             }
  811.  
  812.             /*-----------------------*/
  813.             /* Check GD_LARGESTFAST: */
  814.             /*-----------------------*/
  815.             if (x >= 434 && x <= 459 && y >= 40 && y <= 50)
  816.             {
  817.                 Inform (WatcherPrefsWnd, "Help on gadget - Largest Fast -",
  818.                           "This gadget toggles between displaying the largest *Fast*\n"
  819.                           "memory block available on your system.", NULL);
  820.                 break;
  821.             }
  822.  
  823.             /*-----------------------*/
  824.             /* Check GD_LARGESTCHIP: */
  825.             /*-----------------------*/
  826.             if (x >= 434 && x <= 459 && y >= 29 && y <= 39)
  827.             {
  828.                 Inform (WatcherPrefsWnd, "Help on gadget - Largest Chip -",
  829.                           "This gadget toggles between displaying the largest *Chip*\n"
  830.                           "memory block available on your system.", NULL);
  831.                 break;
  832.             }
  833.  
  834.             /*---------------------*/
  835.             /* Check GD_DAYOFWEEK: */
  836.             /*---------------------*/
  837.             if (x >= 465 && x <= 490 && y >= 84 && y <= 94)
  838.             {
  839.                 Inform (WatcherPrefsWnd, "Help on gadget - Day Of Week -",
  840.                           "This gadget toggles between displaying the day of week.\n"
  841.                           "Watcher will display the day of week localized according\n"
  842.                           "to your local settings, eg. Donnerstag or Monday etc.", NULL);
  843.                 break;
  844.             }
  845.  
  846.             /*----------------*/
  847.             /* Check GD_DATE: */
  848.             /*----------------*/
  849.             if (x >= 465 && x <= 490 && y >= 73 && y <= 83)
  850.             {
  851.                 Inform (WatcherPrefsWnd, "Help on gadget - Date -",
  852.                           "This gadget toggles between displaying the date.\n"
  853.                           "The date is displayed as dd-mm-yy.", NULL);
  854.                 break;
  855.             }
  856.  
  857.             /*----------------*/
  858.             /* Check GD_TIME: */
  859.             /*----------------*/
  860.             if (x >= 465 && x <= 490 && y >= 62 && y <= 72)
  861.             {
  862.                 Inform (WatcherPrefsWnd, "Help on gadget - Time -",
  863.                           "This gadget toggles between displaying the time.\n"
  864.                           "The time is displayed as hh:mm:ss.", NULL);
  865.                 break;
  866.             }
  867.  
  868.             /*-----------------------*/
  869.             /* Check GD_WINLEFTEDGE: */
  870.             /*-----------------------*/
  871.             if (x >= 222 && x <= 270 && y >= 46 && y <= 59)
  872.             {
  873.                 Inform (WatcherPrefsWnd, "Help on gadget - Window LeftEdge -",
  874.                           "Here you enter the left edge position of the Watcher window.", NULL);
  875.                 break;
  876.             }
  877.  
  878.             /*----------------------*/
  879.             /* Check GD_WINTOPEDGE: */
  880.             /*----------------------*/
  881.             if (x >= 222 && x <= 270 && y >= 61 && y <= 74)
  882.             {
  883.                 Inform (WatcherPrefsWnd, "Help on gadget - Window TopEdge -",
  884.                           "Here you enter the top edge position of the Watcher window.", NULL);
  885.                 break;
  886.             }
  887.  
  888.             /*--------------------*/
  889.             /* Check GD_WINWIDTH: */
  890.             /*--------------------*/
  891.             if (x >= 222 && x <= 270 && y >= 76 && y <= 89)
  892.             {
  893.                 Inform (WatcherPrefsWnd, "Help on gadget - Window Width -",
  894.                           "Here you enter the width of the Watcher window. Use 0\n"
  895.                           "to make the Watcher window conform to maximum overscan.", NULL);
  896.                 break;
  897.             }
  898.  
  899.             /*---------------------*/
  900.             /* Check GD_UPDATESEC: */
  901.             /*---------------------*/
  902.             if (x >= 222 && x <= 270 && y >= 91 && y <= 104)
  903.             {
  904.                 Inform (WatcherPrefsWnd, "Help on gadget - Update rate sec. -",
  905.                           "Here you enter the update rate in seconds. If you set\n"
  906.                           "this value to eg. '1', then Watcher will update it's\n"
  907.                           "display once a second. Note that the more frequent\n"
  908.                           "Watcher must update it's display, the more CPU Watcher\n"
  909.                           "eats.", NULL);
  910.                 break;
  911.             }
  912.  
  913.             /*---------------------*/
  914.             /* Check GD_UPDATEMIC: */
  915.             /*---------------------*/
  916.             if (x >= 222 && x <= 270 && y >= 106 && y <= 119)
  917.             {
  918.                 Inform (WatcherPrefsWnd, "Help on gadget - Update rate mic. -",
  919.                           "Here you enter Watcher's update rate in microseconds.\n"
  920.                           "Usually this is left to zero - see help for Update rate sec.", NULL);
  921.                 break;
  922.             }
  923.  
  924.             /*------------------------*/
  925.             /* Check GD_NOJUMPGADGET: */
  926.             /*------------------------*/
  927.             if (x >= 465 && x <= 490 && y >= 51 && y <= 61)
  928.             {
  929.                 Inform (WatcherPrefsWnd, "Help on gadget - No Jump Gadget -",
  930.                           "By default Watcher will put a Zoom gadget rightmost\n"
  931.                           "on the title bar. Hitting this gadget causes Watcher\n"
  932.                           "to jump to the next public screen (if any). Since this\n"
  933.                           "gadget occupies space on the title bar, you can choose\n"
  934.                           "to omit this gadget by selecting this option.", NULL);
  935.                 break;
  936.             }
  937.  
  938.             /*---------------*/
  939.             /* Check GD_CPU: */
  940.             /*---------------*/
  941.             if (x >= 465 && x <= 490 && y >= 40 && y <= 50)
  942.             {
  943.                 Inform (WatcherPrefsWnd, "Help on gadget - Cpu -",
  944.                           "This toggles between displaying your system's CPU load.\n"
  945.                           "The CPU load indicates how busy in percent your CPU is.", NULL);
  946.                 break;
  947.             }
  948.             /*------------------------*/
  949.             /* Check GD_PUBLICSCREEN: */
  950.             /*------------------------*/
  951.             if (x >= 140 && x <= 270 && y >= 121 && y <= 134)
  952.             {
  953.                 Inform (WatcherPrefsWnd, "Help on gadget - Public Screen -",
  954.                           "Here you enter the name of the Public Screen you want\n"
  955.                           "Watcher to initially open on. If you leave this gadget\n"
  956.                           "empty Watcher will initially open on the Workbench.", NULL);
  957.                 break;
  958.             }
  959.  
  960.             /*---------------------*/
  961.             /* Check GD_GUIDEFILE: */
  962.             /*---------------------*/
  963.             if (x >= 140 && x <= 270 && y >= 136 && y <= 149)
  964.             {
  965.                 Inform (WatcherPrefsWnd, "Help on gadget - Guide File -",
  966.                           "Here you enter the full path of the Watcher guide file.\n"
  967.                           "Watcher uses this guide file to display on-line help,\n"
  968.                           "that is whenever you press the HELP key when Watcher is\n"
  969.                           "active.", NULL);
  970.                 break;
  971.             }
  972.  
  973.             /*-------------------------------*/
  974.             /* Check GD_VOLUMEFREEDIRECTION: */
  975.             /*-------------------------------*/
  976.             if (x >= 465 && x <= 490 && y >= 29 && y <= 39)
  977.             {
  978.                 Inform (WatcherPrefsWnd, "Help on gadget - Volume Free Direction -",
  979.                           "This gadget toggles between displaying Volume Free Direction\n"
  980.                           "Indicators. By default the characters '-', '^' and 'v' are\n"
  981.                           "used to indicate whether a volume is gaining (^) or loosing (v)\n"
  982.                           "free space, or whether it has not changed (-). This indicators\n"
  983.                           "are displayed immediately before the free space number on the\n"
  984.                           "title bar. See also the help for Volume Free Direction Indicators.", NULL);
  985.                 break;
  986.             }
  987.  
  988.             /*-----------------------------------------*/
  989.             /* Check GD_VOLUMEFREEDIRECTIONINDICATORS: */
  990.             /*-----------------------------------------*/
  991.             if (x >= 224 && x <= 270 && y >= 151 && y <= 164)
  992.             {
  993.                 Inform (WatcherPrefsWnd, "Help on gadget - Volume Free Indicators -",
  994.                           "Here you specify the three volume free indicator values. The\n"
  995.                           "first character is the character to use when there is no change\n"
  996.                           "in the volumes free space (defaults to '-'). The second\n"
  997.                           "character is displayed when the volume is gaining space (defaults\n"
  998.                           "to '^'). The last character is used to indicate when the volume\n"
  999.                           "is loosing space (defaults to 'v').", NULL);
  1000.                 break;
  1001.             }
  1002.  
  1003.             /*-----------------------*/
  1004.             /* Check GD_VOLUMEALERT: */
  1005.             /*-----------------------*/
  1006.             if (x >= 140 && x <= 270 && y >= 166 && y <= 179)
  1007.             {
  1008.                 Inform (WatcherPrefsWnd, "Help on gadget - Volume Alert -",
  1009.                           "Here you enter which volumes you would like to get alerts\n"
  1010.                           "for. This means that if enter eg. SYS:-m1,WORK:-m5, then\n"
  1011.                           "you will be notified with a requester whenever SYS: hits\n"
  1012.                           "or gets below 1 MB of free space, and for WORK: this limit\n"
  1013.                           "is set to 5 MB in our example.", NULL);
  1014.                 break;
  1015.             }
  1016.  
  1017.             /*----------------*/
  1018.             /* Check GD_SAVE: */
  1019.             /*----------------*/
  1020.             if (x >= 8 && x <= 98 && y >= 217 && y <= 231)
  1021.             {
  1022.                 Inform (WatcherPrefsWnd, "Help on gadget - Save -",
  1023.                           "This will save the current settings and make the permanent.\n"
  1024.                           "This means that the file Watcher.prefs will be written to\n"
  1025.                           "both ENVARC: and ENV:.", NULL);
  1026.                 break;
  1027.             }
  1028.  
  1029.             /*---------------*/
  1030.             /* Check GD_USE: */
  1031.             /*---------------*/
  1032.             if (x >= 271 && x <= 361 && y >= 217 && y <= 231)
  1033.             {
  1034.                 Inform (WatcherPrefsWnd, "Help on gadget - Use -",
  1035.                           "This will save the current settings to ENV:Watcher.prefs,\n"
  1036.                           "meaning that the settings will not be permanent, and only\n"
  1037.                           "have effect until the next time you reboot your machine.", NULL);
  1038.                 break;
  1039.             }
  1040.  
  1041.             /*------------------*/
  1042.             /* Check GD_CANCEL: */
  1043.             /*------------------*/
  1044.             if (x >= 531 && x <= 621 && y >= 217 && y <= 231)
  1045.             {
  1046.                 Inform (WatcherPrefsWnd, "Help on gadget - Cancel -",
  1047.                           "This will cancel your current settings and *NOT* save\n"
  1048.                           "the settings to disk.", NULL);
  1049.                 break;
  1050.             }
  1051.  
  1052.             /*------------------------*/
  1053.             /* Check GD_GUIDEFILEGET: */
  1054.             /*------------------------*/
  1055.             if (x >= 271 && x <= 290 && y >= 136 && y <= 149)
  1056.             {
  1057.                 Inform (WatcherPrefsWnd, "Help on gadget - Get Guide File. -",
  1058.                           "Hitting this gadget will invoke a file requester, asking\n"
  1059.                           "you to choose where the Watcher.guide file is located. This\n"
  1060.                           "file is used by Watcher to display context sensitive on-line\n"
  1061.                           "help.", NULL);
  1062.                 break;
  1063.             }
  1064.  
  1065.             /*---------------------------*/
  1066.             /* Check GD_APPINFOLEFTEDGE: */
  1067.             /*---------------------------*/
  1068.             if (x >= 221 && x <= 269 && y >= 180 && y <= 193)
  1069.             {
  1070.                 Inform (WatcherPrefsWnd, "Help on gadget - App Info Left Edge -",
  1071.                           "Here you specify the initial Left Edge of the App Info icon.\n"
  1072.                           "This enables you to position the App Info icon at your preferred\n"
  1073.                           "position. Using 0, 0 as the top and left edge, will position\n"
  1074.                           "the appicon at a free position closest to 0, 0.", NULL);
  1075.                 break;
  1076.             }
  1077.  
  1078.             /*--------------------------*/
  1079.             /* Check GD_APPINFOTOPEDGE: */
  1080.             /*--------------------------*/
  1081.             if (x >= 221 && x <= 269 && y >= 194 && y <= 207)
  1082.             {
  1083.                 Inform (WatcherPrefsWnd, "Help on gadget - App Info Top Edge -",
  1084.                           "Here you specify the initial Top Edge of the App Info icon.\n"
  1085.                           "This enables you to position the App Info icon at your preferred\n"
  1086.                           "position.Using 0, 0 as the top and left edge, will position\n"
  1087.                           "the appicon at a free position closest to 0, 0.", NULL);
  1088.                 break;
  1089.             }
  1090.  
  1091.             /*----------------------------*/
  1092.             /* Check GD_APPINFOAUTOSTART: */
  1093.             /*----------------------------*/
  1094.             if (x >= 434 && x <= 459 && y >= 95 && y <= 105)
  1095.             {
  1096.                 Inform (WatcherPrefsWnd, "Help on gadget - App Info autostart -",
  1097.                           "Here you specify if you want the App Info to start automatically.\n"
  1098.                           "This means that when Watcher starts up, the App Info icon is\n"
  1099.                           "automatically activated. You can ofcourse specify the opposite by\n"
  1100.                           "disabling this feature.", NULL);
  1101.                 break;
  1102.             }
  1103.  
  1104.             /*-----------------------*/
  1105.             /* Check GD_DATE_FORMAT: */
  1106.             /*-----------------------*/
  1107.             if (x >= 360 && x < 459 && y >= 106 && y <= 119)
  1108.             {
  1109.                 Inform (WatcherPrefsWnd, "Help on gadget - Date Format -",
  1110.                           "This gadget let's you specify the format of the displayed date.", NULL);
  1111.                 break;
  1112.             }
  1113.  
  1114.             /*-----------------------*/
  1115.             /* Check GD_TIME_FORMAT: */
  1116.             /*-----------------------*/
  1117.             if (x >= 465 && x < 490 && y >= 95 && y <= 105)
  1118.             {
  1119.                 Inform (WatcherPrefsWnd, "Help on gadget - 24 Hour Clock -",
  1120.                           "This gadget let's you specify if you want a 24 hour or 12 hour\n"
  1121.                           "clock displayed in the window of Watcher.", NULL);
  1122.                 break;
  1123.             }
  1124.  
  1125.             /*--------------------*/
  1126.             /* Check GD_LANGUAGE: */
  1127.             /*--------------------*/
  1128.             if (x >= 465 && x < 615 && y >= 106 && y <= 193)
  1129.             {
  1130.                 Inform (WatcherPrefsWnd, "Help on gadget - Date Format -",
  1131.                           "Here you can specify which language you want Watcher to use.\n"
  1132.                           "NOTE! Changing language will first have effect when you quit,\n"
  1133.                           "      and restart Watcher.", NULL);
  1134.                 break;
  1135.             }
  1136.  
  1137.             /*-------------------------------------------------*/
  1138.             /* If we enter here, the use is not over a gadget. */
  1139.             /*-------------------------------------------------*/
  1140.             Inform (WatcherPrefsWnd, "WatcherPrefs Help System:",
  1141.                       "You have hit help without placing the mouse pointer over a\n"
  1142.                       "gadget or invoking the menu. In order to get help, simply\n"
  1143.                       "place your mouse pointer of the desired gadget and press\n"
  1144.                       "help. Menu help is also available, select the menu item with\n"
  1145.                       "the right mouse button and press help while still holding\n"
  1146.                       "down the right mouse button.", NULL);
  1147.             break;
  1148.         }
  1149.     }
  1150.     return (1);
  1151. }
  1152.